/*
 * @Author: c
 * @Date: 2024-01-08 17:26:19
 * @LastEditTime: 2024-01-26 19:50:48
 * @LastEditors: c
 * @Description: 
 * @FilePath: \music-web-backend\src\core\music\picture\entities\picture.entity.ts
 * https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { Artist } from "src/core/music/artist/entities/artist.entity";
import { FileInfo } from "src/core/system/minio/entities/file_info.entity";
import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
import { PictorialEnum } from "../enum";
import { Song } from "../../song/entities/song.entity";

@Entity({ name: "picture" })
export class Picture {

    constructor(url: string, type: PictorialEnum) {
        this.url = url;
        this.picType = type;

    }

    @PrimaryGeneratedColumn('uuid')
    id: string;

    @Column({
        type: "varchar",
        length: 500,
        comment: "图片链接",
        nullable: true
    })
    url: string;


    @Column({
        type: 'enum',
        name: "pic_type",
        enum: PictorialEnum,
        default: PictorialEnum.NULL,
        nullable: false,
        comment: "图片类型 (NULL:未知,1:头像,2:画廊)"
    })
    picType: PictorialEnum

    @Column({
        type: 'boolean',
        default: true,
        nullable: false,
        comment: "相册状态(true:使用中,false:未使用)"
    })
    isActive: boolean

    @Column({
        type: 'boolean',
        default: false,
        nullable: false,
        comment: "相册是否删除 (1:删除,0:未删除)"
    })
    deleted: boolean;

    @CreateDateColumn({
        name: "create_time",
        nullable: false,
    })
    createTime: Date;

    @UpdateDateColumn({
        name: "update_time",
        nullable: false,
    })
    updateTime: Date;

    @DeleteDateColumn({
        name: "deleted_time",
        nullable: false,
    })
    deletedTime: Date;



    //关联到歌手实体 多对一 关系
    @ManyToOne(() => Artist, artist => artist.pictures, {})
    @JoinColumn({
        name: 'artist_id',
        referencedColumnName: "id",
    })
    artist: Artist;

   

    //关联到文件实体 一对一 关系
    @OneToOne(() => FileInfo)
    @JoinColumn({
        name: 'file_id',
        referencedColumnName: "id",
    })
    fileInfo: FileInfo;



}
